package prob2;

import java.util.*;

public class Bubble_Sort {
    static void Sort(ArrayList collection, Comparator comparator)
    {
        for (int i = 0; i < collection.size()- 1; i++) {
            for (int j = 0; j < collection.size() - i -1; j++) {
                if (comparator.compare(collection.get(j+1),collection.get(j)) > 0) {
                    Collections.swap(collection,j,j+1);
                }
            }
        }
    }
    static void Sort(Comparable[] collection)
    {
        for (int i = 0; i < collection.length- 1; i++) {
            for (int j = 0; j < collection.length - i -1; j++) {
                if (collection[j+1].compareTo(collection[j]) > 0) {
                    Collections.swap(Arrays.asList(collection),j,j+1);
                }
            }
        }
    }
}
